package com.zzgc.modules.controller;

import com.zzgc.common.entity.AuthRight;
import com.zzgc.common.response.HttpStatus;
import com.zzgc.common.response.Result;
import com.zzgc.modules.log.ApiLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 权限管理类
 * @Author:
 * @CreateTime: 2022-11-19  16:51
 * @Description:
 * @Version: 1.0
 */
@RestController
@Api(tags = "权限管理")
@ApiLog(value = "权限管理类", url = "auth/role")
@RequestMapping("auth/role")
public class AuthRoleController extends BaseController {

    /**
     * 根据token获取目录
     * @ClassName AuthRoleController
     * @Date 2022/11/19  17:14
     * @Version 1.0
     */
    @GetMapping("getRights")
    @ApiLog(value = "根据token获取获取用户权限目录", method = RequestMethod.GET, url = "getRights")
    @ApiOperation(value = "根据token获取目录", notes = "获取用户权限目录")
    public Result getRights(){
        // 用当前角色的id获取列表
        List<AuthRight> roleRights = super.roleService.getRoleRights(Long.valueOf(super.getUserRole()));
        return Result.builder()
                .code(HttpStatus.OK.value())
                .msg(HttpStatus.OK.getReasonPhrase())
                .data(roleRights)
                .build();
    }
}
